<?php
/**
 * Create By: PhpStorm
 * User: niechenguang
 * File: Circle.php
 * Date: 2017/1/2
 * Time: 23:13
 */
namespace app\api\model\dao;

use think\Model;
use think\Db;

class Picture extends Model
{
    protected $table = 'picture';

    protected $pk = 'id';

    /**
     * 添加图片记录
     *
     */
    public function addPicture($arrInput)
    {
        unset($arrInput[$this->pk]);

        $this->data($arrInput);
        $this->save();
        return $this->data[$this->pk];
    }

    /**
     * 获取某对象关联的图片
     *
     */
    public function getPicture($userid, $type, $obj_id)
    {
        $arrCond = [
            'userid' => ['=', $userid],
            'type' => ['=', $type],
            'obj_id' => ['=', $obj_id],
        ];

        return Db::table($this->table)->where($arrCond)->select();
    }

}
